/**
 * 
 */
package com.zcsy.manage.service.common;

import java.util.List;

import javax.servlet.http.HttpSession;

import com.zcsy.commons.model.RequestConstants;
import com.zcsy.commons.model.RequestContext;
import com.zcsy.manage.model.system.Menu;
import com.zcsy.manage.model.system.User;


/**  
 * @Project: service
 * @Title: CommonService.java
 * @Package com.zcsy.manage.service.common
 * @Description: 所有service的基类，重用性很高或公共的方法可写在这里
 *
 * @author xiangjw 303310059@qq.com
 * @date 2016年1月11日 下午5:55:06
 * @Copyright: 2016 武汉中财数元信息技术有限公司 All rights reserved.
 * @version V1.0  
 */
public class CommonService {

	/** 
	 * @Title: getSessionUser 
	 * @Description: 获取当前用户信息
	 * @param @return     
	 * @return User     
	 * @throws 
	 */
	public static User getSessionUser(){
		HttpSession session = RequestContext.getSession();
		return (User)session.getAttribute(RequestConstants.USER_SESSION_ID);
	}
	
	/** 
	 * @Title: setSessionUser 
	 * @Description: 设置用户信息
	 * @param @param info     
	 * @return void     
	 * @throws 
	 */
	public static void setSessionUser(User info){
		HttpSession session = RequestContext.getSession();
		session.setAttribute(RequestConstants.USER_SESSION_ID , info);
	}
	
	/**
	 * 获取当前用户菜单信息
	 * 
	 * @return
	 */
	public static List<Menu> getSessionMenus(){
		HttpSession session = RequestContext.getSession();
		return (List<Menu>)session.getAttribute(RequestConstants.MENUS);
	}
	
	/** 
	 * @Title: setSessionMenus 
	 * @Description: 设置菜单信息
	 * @param @param info     
	 * @return void     
	 * @throws 
	 */
	public static void setSessionMenus(List<Menu> info){
		HttpSession session = RequestContext.getSession();
		session.setAttribute(RequestConstants.MENUS , info);
	}
	
	/**
	 * 获取当前用户菜单数组信息
	 * 
	 * @return
	 */
	public static List<Menu> getSessionMenusArray(){
		HttpSession session = RequestContext.getSession();
		return (List<Menu>)session.getAttribute(RequestConstants.MENUS_ARRAY);
	}
	
	/** 
	 * @Title: setSessionMenusArray 
	 * @Description: 设置当前用户菜单数组信息
	 * @param @param info     
	 * @return void     
	 * @throws 
	 */
	public static void setSessionMenusArray(List<Menu> info){
		HttpSession session = RequestContext.getSession();
		session.setAttribute(RequestConstants.MENUS_ARRAY , info);
	}
}
